var MongoClient = require('mongodb').MongoClient;
// var dbUrl = 'mongodb://localhost:27017/';
var dbUrl = 'mongodb://admin:123@localhost:27017/';
var dbName = 'test2';


MongoClient.connect(dbUrl,{ useNewUrlParser: true },(err, client)=>{
    if(err){
        console.log(err);
        return;
    }
var db = client.db(dbName)

    db.collection('user').insertOne({'name':"张三",'age':18,gender:true},function (err, result) {
        if(err){
            console.log(err)
        }else{
            console.log(result)
            client.close();
        }
    })
});













